package common;

import java.io.PrintStream;
import java.util.Vector;

public class InfoElement {
	private Token token = new Token( TokenType.ENDFILE , null );
	private String lexeme = "";
	private Vector<String> parserInfo = new Vector<String>() ;
	
	public InfoElement( Token tokenInfo , String lexime ) {
		this.token = tokenInfo;
		this.lexeme = lexime;
	}
	
	public void addParserInfo( String info ){
		parserInfo.add( info );
	}
	
	public void printToLog( PrintStream writer, int lineNum){
		if( parserInfo!=null && writer!=null ){
			String msg = "\t" + String.valueOf(lineNum) + ":" + token;
			if( ( token.getType()==TokenType.ID ) || ( token.getType()==TokenType.ERROR ) ){
				msg += " => \"" + lexeme + "\"";
			}
			writer.println(msg);
			for( int i = 0; i<parserInfo.size(); i++){
				writer.println( '\t'+parserInfo.get(i));
			}
		}
	}
}
